#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
const int maxn =101;

int map[maxn][maxn],n;

int main(){

	cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cin>>map[i][j];
		}
	}
	
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			map[i][j]=min(map[i-1][j],map[i][j-1])+map[i][j];
			if(i==1)map[i][j]+=map[i][j-1];
			if(j==1)map[i][j]+=map[i-1][j];
		}
	}
	
	cout<<map[n][n]<<endl;
	
	return 0;
}